package com.wanmait.houlang.controller;

import com.github.pagehelper.PageInfo;
import com.wanmait.houlang.pojo.DTO;
import com.wanmait.houlang.pojo.ScScorePro;
import com.wanmait.houlang.service.EpikHighService;
import com.wanmait.houlang.service.ScScoreProService;
import com.wanmait.houlang.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/webContent")
public class ChooseSchoolController {
    @Resource
    private EpikHighService epikHighService;
    @Resource
    private ScScoreProService scScoreProService;
    //根据高考成绩以及科目代码获取高考位次
    @GetMapping("/searchPrecedence/{score:\\d+}/{subjectCodes}")
    public Result searchPrecedence(@PathVariable String score,@PathVariable String subjectCodes){
        Integer precedenceBySubjectCodeAndScore = epikHighService.findPrecedenceBySubjectCodeAndScore(score, subjectCodes);
        return Result.success(precedenceBySubjectCodeAndScore);
    }
//推荐学校
    @PostMapping("recommendedSchools")
    public Result recommendedSchools(Integer pageNum,@RequestBody DTO dto){
        Integer pageSize=5;
        PageInfo<ScScorePro> scScoreProByScore = scScoreProService.findScScoreProByScore(pageNum, pageSize, dto);
        return Result.success(scScoreProByScore);
    }
}
